Ext.define('App.controller.bbsReply.BbsReplyViewController', {
	extend : 'Ext.app.ViewController',
	alias : 'controller.bbsReplyViewController',
	menu : Ext.widget('menu'),
	control : {
		'bbsReplyView bbsReplyList' : {
			beforerender : function(grid) {
				var buttons = {
					'bs/bbsReply/saveBbsReply' : function(permit) {
						BaseUtil.createView('bbsReply.BbsReplyWindow',permit,{storeId:'bbsReply.BbsReplyStore'}).show();
					}
				};
				BaseUtil.createPermitTbar(grid, buttons);
			},
			itemcontextmenu : function(view, record, item, index, e) {
				var id = record.get('id');
				var menuitems = {
					'bs/bbsReply/updateBbsReply' : function(permit) {
						var win = BaseUtil.createView('bbsReply.BbsReplyWindow',permit,{storeId:'bbsReply.BbsReplyStore'});
						win.down('form').loadRecord(record);
						win.show();
					}
				};
				var status = record.get('status'),store = Ext.StoreMgr.get('bbsReply.BbsReplyStore');
				if(status === StatusEnum.DELETE.getValue()){
					menuitems['bs/bbsReply/recover'] = function(permit) {
						BaseUtil.statusConfirm('确认恢复此记录吗?',permit.url,id,store);
					}
				}else{
					menuitems['bs/bbsReply/removeBbsReply'] = function(permit) {
						BaseUtil.statusConfirm('确认删除此记录吗?',permit.url,id,store);
					}
				}
				BaseUtil.createPermitMenu(view, this.menu, e, menuitems);
			},
			render : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('bbsReply.BbsReplyStore'),Ext.getCmp('bbsReplyView').down('bbsReplySearch form').getForm().getFieldValues());
			}
		},
		'bbsReplyView bbsReplySearch [action=search] ' : {
			click : function() {
				BaseUtil.loadStore(Ext.StoreMgr.get('bbsReply.BbsReplyStore'),Ext.getCmp('bbsReplyView').down('bbsReplySearch form').getForm().getFieldValues());
			}
		}
	}
});